package projet_v1.simulation.events;

import static org.junit.Assert.*;

import java.awt.Dimension;
import java.util.ArrayList;
import java.util.List;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import projet_v1.Character;
import projet_v1.Vampire;
import projet_v1.simulation.Field;
import projet_v1.simulation.Location;

public class TestChimicalAttack {

	private ChimicalAttack c;

	@Before
	public void setUp() throws Exception {
		c = new ChimicalAttack(new Location(5, 5));
	}

	@After
	public void tearDown() throws Exception {
		c = null;
	}

	@Test
	public void testHappend() {
		Field f = new Field(6, 6);
		List<Character> characters = new ArrayList<Character>();
		f.clear();
		for (int row = 0; row < f.getDepth(); row++) {
			for (int col = 0; col < f.getWidth(); col++) {
				Location loc = new Location(row, col);
				Vampire v = new Vampire(Vampire.HP_VAMPIRES, f, loc);
				f.place(v, row, col);
				characters.add(v);
			}
		}

		c.happend(characters, f);

		for (Character character : characters) {
			assertEquals(false, character.isAlive());
		}
	}

	@Test
	public void testGetTypeEvent() {
		assertEquals(Event.IS_GOOD_FOR_HUMANITY, c.getTypeEvent());
	}

	@Test
	public void testChangeStartLocation() {
		c.changeStartLocation(new Location(3, 3));
		assertEquals(3, c.getStartLocation().getCol());
		assertEquals(3, c.getStartLocation().getRow());
	}

}
